<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //
    class Computer{
      //属性
      price;
      run(){
        console.log('运行-2');
      }
      arrow = () => {
        alert('箭头函数也可以哦~~~')
      }

      //静态属性 static
      static name = '计算机';

      //特殊的方法  构造方法   作用: 初始化实例对象
      constructor(brand, price, color){
        this.brand = brand;
        this.price = price;
        this.color = color;
      }

      //方法
      playGame(){
        console.log('play game');
      }

      //静态方法
      static program(){
        console.log('可以编程哦~~');
      }
    }
    // let thinkPad = new Computer('联想',4200, '黑色');

    //继承
    class Lapbook extends Computer{
      screen; //屏幕大小
      storage; // 存储空间

      constructor(brand, price, color, screen, storage){
        //子类构造方法中, 一定要调用 super 函数.  super 就是父类的构造方法
        super(brand, price, color);
        //子类实例初始化
        this.screen = screen;
        this.storage = storage;
      }

      run() {
        console.log('我可以运行程序哦~~');
      }
    }

    //实例化
    let xiaomi = new Lapbook('华为', 9000, '白色', '15.6inch', '1T');

    console.log(xiaomi);


    xiaomi.run();    

  </script>
</body>
</html>